package dream.flying.flower.db.enums;

/**
 * 数据库类型
 *
 * @author 飞花梦影
 * @date 2024-07-31 14:32:05
 * @git {@link https://github.com/dreamFlyingFlower}
 */
public enum DbType {

	/**
	 * MYSQL
	 */
	MYSQL("mysql", "MySql数据库"),
	/**
	 * MARIADB
	 */
	MARIADB("mariadb", "MariaDB数据库"),
	/**
	 * ORACLE
	 */
	ORACLE("oracle", "Oracle11g及以下数据库(高版本推荐使用ORACLE_NEW)"),
	/**
	 * oracle12c new pagination
	 */
	ORACLE_12C("oracle12c", "Oracle12c+数据库"),
	/**
	 * DB2
	 */
	DB2("db2", "DB2数据库"),
	/**
	 * H2
	 */
	H2("h2", "H2数据库"),
	/**
	 * HSQL
	 */
	HSQL("hsql", "HSQL数据库"),
	/**
	 * SQLITE
	 */
	SQLITE("sqlite", "SQLite数据库"),
	/**
	 * POSTGRE
	 */
	POSTGRE_SQL("postgresql", "Postgre数据库"),
	/**
	 * SQLSERVER2005
	 */
	SQL_SERVER2005("sqlserver2005", "SQLServer2005数据库"),
	/**
	 * SQLSERVER
	 */
	SQL_SERVER("sqlserver", "SQLServer数据库"),
	/**
	 * DM
	 */
	DM("dm", "达梦数据库"),
	/**
	 * xugu
	 */
	XU_GU("xugu", "虚谷数据库"),
	/**
	 * Kingbase
	 */
	KINGBASE_ES("kingbasees", "人大金仓数据库"),
	/**
	 * Phoenix
	 */
	PHOENIX("phoenix", "Phoenix HBase数据库"),
	/**
	 * Gauss
	 */
	GAUSS("zenith", "Gauss 数据库"),
	/**
	 * ClickHouse
	 */
	CLICK_HOUSE("clickhouse", "clickhouse 数据库"),
	/**
	 * GBase
	 */
	GBASE("gbase", "南大通用(华库)数据库"),
	/**
	 * GBase-8s
	 */
	GBASE_8S("gbase-8s", "南大通用数据库 GBase 8s"),
	/**
	 * GBase8sPG
	 */
	GBASE8S_PG("gbase8s-pg", "南大通用数据库 GBase 8s兼容pg"),
	/**
	 * GBase8c
	 */
	GBASE_8C("gbase8c", "南大通用数据库 GBase 8c"),
	/**
	 * Sinodb
	 */
	SINODB("sinodb", "星瑞格数据库"),
	/**
	 * Oscar
	 */
	OSCAR("oscar", "神通数据库"),
	/**
	 * Sybase
	 */
	SYBASE("sybase", "Sybase ASE 数据库"),
	/**
	 * OceanBase
	 */
	OCEAN_BASE("oceanbase", "OceanBase 数据库"),
	/**
	 * Firebird
	 */
	FIREBIRD("Firebird", "Firebird 数据库"),
	/**
	 * HighGo
	 */
	HIGH_GO("highgo", "瀚高数据库"),
	/**
	 * CUBRID
	 */
	CUBRID("cubrid", "CUBRID数据库"),
	/**
	 * SUNDB
	 */
	SUNDB("sundb", "SUNDB数据库"),
	/**
	 * Hana
	 */
	SAP_HANA("hana", "SAP_HANA数据库"),
	/**
	 * Impala
	 */
	IMPALA("impala", "impala数据库"),
	/**
	 * Vertica
	 */
	VERTICA("vertica", "vertica数据库"),
	/**
	 * xcloud
	 */
	XCloud("xcloud", "行云数据库"),
	/**
	 * redshift
	 */
	REDSHIFT("redshift", "亚马逊redshift数据库"),
	/**
	 * openGauss
	 */
	OPENGAUSS("openGauss", "华为 opengauss 数据库"),
	/**
	 * TDengine
	 */
	TDENGINE("TDengine", "TDengine数据库"),
	/**
	 * Informix
	 */
	INFORMIX("informix", "Informix数据库"),
	/**
	 * uxdb
	 */
	UXDB("uxdb", "优炫数据库"),
	/**
	 * lealone
	 */
	LEALONE("lealone", "Lealone数据库"),
	/**
	 * trino
	 */
	TRINO("trino", "Trino数据库"),
	/**
	 * presto
	 */
	PRESTO("presto", "Presto数据库"),
	/**
	 * UNKNOWN DB
	 */
	OTHER("other", "其他数据库");

	/**
	 * 数据库名称
	 */
	private final String name;

	/**
	 * 描述
	 */
	private final String msg;

	DbType(String name, String msg) {
		this.name = name;
		this.msg = msg;
	}

	/**
	 * 获取数据库类型
	 *
	 * @param dbType 数据库类型字符串
	 */
	public static DbType getDbType(String dbType) {
		for (DbType type : DbType.values()) {
			if (type.name.equalsIgnoreCase(dbType)) {
				return type;
			}
		}
		return OTHER;
	}

	public boolean mysqlSameType() {
		return this == DbType.MYSQL || this == DbType.MARIADB || this == DbType.GBASE || this == DbType.OSCAR
				|| this == DbType.XU_GU || this == DbType.CLICK_HOUSE || this == DbType.OCEAN_BASE
				|| this == DbType.CUBRID || this == DbType.SUNDB;
	}

	public boolean oracleSameType() {
		return this == DbType.ORACLE || this == DbType.DM || this == DbType.GAUSS;
	}

	public boolean postgresqlSameType() {
		return this == DbType.POSTGRE_SQL || this == DbType.H2 || this == DbType.LEALONE || this == DbType.SQLITE
				|| this == DbType.HSQL || this == DbType.KINGBASE_ES || this == DbType.PHOENIX
				|| this == DbType.SAP_HANA || this == DbType.IMPALA || this == DbType.HIGH_GO || this == DbType.VERTICA
				|| this == DbType.REDSHIFT || this == DbType.OPENGAUSS || this == DbType.TDENGINE || this == DbType.UXDB
				|| this == DbType.GBASE8S_PG || this == DbType.GBASE_8C;
	}

	public String getMsg() {
		return this.msg;
	}

	public String getName() {
		return this.name;
	}
}